package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DrTypeModeGroup;
import com.ruoyi.system.service.IDrTypeModeGroupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 全局变量分组Controller
 * 
 * @author yaozh
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/system/globalgroup")
public class DrTypeModeGroupController extends BaseController
{
    @Autowired
    private IDrTypeModeGroupService drTypeModeGroupService;

    /**
     * 查询全局变量分组列表
     */
    @PreAuthorize("@ss.hasPermi('system:globalgroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(DrTypeModeGroup drTypeModeGroup)
    {
        startPage();
        List<DrTypeModeGroup> list = drTypeModeGroupService.selectDrTypeModeGroupList(drTypeModeGroup);
        return getDataTable(list);
    }

    /**
     * 导出全局变量分组列表
     */
    @PreAuthorize("@ss.hasPermi('system:globalgroup:export')")
    @Log(title = "全局变量分组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DrTypeModeGroup drTypeModeGroup)
    {
        List<DrTypeModeGroup> list = drTypeModeGroupService.selectDrTypeModeGroupList(drTypeModeGroup);
        ExcelUtil<DrTypeModeGroup> util = new ExcelUtil<DrTypeModeGroup>(DrTypeModeGroup.class);
        util.exportExcel(response, list, "全局变量分组数据");
    }

    /**
     * 获取全局变量分组详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:globalgroup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(drTypeModeGroupService.selectDrTypeModeGroupById(id));
    }

    /**
     * 新增全局变量分组
     */
    @PreAuthorize("@ss.hasPermi('system:globalgroup:add')")
    @Log(title = "全局变量分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DrTypeModeGroup drTypeModeGroup)
    {
        return toAjax(drTypeModeGroupService.insertDrTypeModeGroup(drTypeModeGroup));
    }

    /**
     * 修改全局变量分组
     */
    @PreAuthorize("@ss.hasPermi('system:globalgroup:edit')")
    @Log(title = "全局变量分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DrTypeModeGroup drTypeModeGroup)
    {
        return toAjax(drTypeModeGroupService.updateDrTypeModeGroup(drTypeModeGroup));
    }

    /**
     * 删除全局变量分组
     */
    @PreAuthorize("@ss.hasPermi('system:globalgroup:remove')")
    @Log(title = "全局变量分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(drTypeModeGroupService.deleteDrTypeModeGroupByIds(ids));
    }
}
